package railRoad.web.slaves;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import railRoad.web.slaves.interfaces.ISlaveServlet;

public class LogoutServlet implements ISlaveServlet {

	public void work(HttpServletRequest req, HttpServletResponse resp)
			throws IOException, ServletException {
		
		boolean auth = (Boolean) req.getSession(true).getAttribute("auth");

		if (Boolean.TRUE.equals(auth)) {
			req.getSession(true).removeAttribute("auth");
			req.getSession().removeAttribute("admin");
			req.getSession().removeAttribute("user_id");
			req.getSession().removeAttribute("passanger_id");
			req.getSession().removeAttribute("body");
		}

		resp.sendRedirect("/index.jsp");
	}

}
